﻿using System;
using System.Collections.Generic;
using Web.SystemConfig.SysCache;

namespace Web.SystemConfig.WorkFlow
{
    public class WorkFlowManager
    {
        /// <summary>
        /// 获取业务实体录入时候的初始状态
        /// </summary>
        /// <param name="tableID"></param>
        /// <returns></returns>
        public int GetOriginalStastuIDByTableID(ArchiveTableEnum tableEnum)
        {
            WorkFlowMessageStatusCache statusCache=new ArchiveCacheFacade().GetStausCache();
            WorkFlowMessageStatus originalStatus = statusCache.GetOrginalMessageStatus(tableEnum);
            if (originalStatus == null)
            {
                throw new Exception("获取缓存信息失败");
            }

            return originalStatus.StatusID;
        }

        /// <summary>
        /// 获取数据在某状态下存在的操作
        /// </summary>
        /// <param name="statusID"></param>
        /// <returns></returns>
        public List<WorkFlowMessageStatusRule> GetRuleByStatusID(int statusID,int fromRoleID)
        {
            return new WorkFlowMessageStatusRuleListCache().GetRuleByStatusID(statusID, fromRoleID);
        }

        /// <summary>
        /// 备注：根据档案分类ID和流程名称取当前状态ID
        /// 时间：2012年12月13日 00:09:21
        /// </summary>
        /// <param name="tableId"></param>
        /// <param name="statusName"></param>
        /// <returns></returns>
        public int GetStatusIdByTableIdAndStatusName(int tableId,string statusName)
        {
            WorkFlowMessageStatusCache statusCache = new ArchiveCacheFacade().GetStausCache();
            return statusCache.GetStatusIdByTableIdAndStatusName(tableId,statusName);
        }
    }
}
